Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Get location of player spawn point on fly

  1. #11
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,567

    Default

    ok this is a drunk man's deed. Are you new to mods ? i thought you knew a lot more about them.
    when you exec a thread, self is the thread and not the player. so self.protected and self.protecting and self stufftext are done on the thread and not the player !
    and you are mixing two logics , the old without reborn logic and the reborn event system logic !
    this script is a mess lol
    I'll fix it.

  2. #12
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,567

    Default

    main: //by RyBack and the very cooperative doublekill
        if(level.spawnprotecton)
            end
        level.spawnprotecton = 1
        local.result = registerev "spawn" global/spawn_protect.scr::spawned
        level.spawnprotectiontime = 6 //spawn protection time
        level.spawnprotectiontime = level.spawnprotectiontime *2
    end
    spawned local.player:
        local.player.spawn_orig = local.player.origin
        local.player nodamage
        local.player.protected = 1
        for(local.i = 0;local.i < level.spawnprotectiontime&&local.player.protected;local.i++)
        {
            if(vector_length(vector_subtract(local.player.spawn_orig-local.player.origin)) > 200)
            {
                local.player.protected = 0
                break
            }
            wait .5
        }
        local.player takedamage
    end

    way easier less messy.
    adjust level.spawnprotectiontime for your needs.
    Last edited by RyBack; June 26th, 2017 at 05:03 AM.

  3. #13

    Default

    self is the thread and not the player. so self.protected and self.protecting and self stufftext are done on the thread and not the player
    good to know ...explains a lot about fixing some of the error messages in my mod....lol

  4. #14
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,567

    Default

    Quote Originally Posted by easymeat View Post
    good to know ...explains a lot about fixing some of the error messages in my mod....lol
    yeh but don't get me wrong, self is thread inside that executed thread.
    but when you do local.player exec blah, then self is the player not the blah thread, Inside the blah thread:
    local.player exec blah
    blah:
    println self.classname //prints "Player"
    end
    _________________________________________________
    exec blah
    blah:
    println self.classname //prints "ScriptThread"
    end

  5. #15

    Default

    Thanks, Ryback. I appreciate that. I was just using an old ass spawn protect script for the spawn protect parts. My goal was to get the killed section working nicely before tackling that. This makes things a lot easier. Thanks again.

    I made just a few adjustments to get it in working order. Turns out the vector_subtract wasn't needed in the code, just vector_length(vector1-vector2) (found from this thread - http://www.x-null.net/forums/showthr...-it-is-started)

    Had a hell of a time figuring that out :P

    I've added in the pieces that I want (lights on players being protected, disabling the script when firing a weapon, getting the script to take the actual player.origin of where you just spawned instead of referencing where you just died). The only issue now is the killed thread. It doesn't seem to be doing much of anything.... Any pointers there? Am I referencing the local.player.spawn_orig incorrectly between threads? I get the iprintln "dead", but not the local.player iprint "..." message, or any of the local.attacker stuff.

    whole scr
    main:  //by RyBack and the very cooperative doublekill
        if(level.spawnprotecton)
            end
        level.spawnprotecton = 1
    
        local.result = registerev "spawn" global/spawn_protect.scr::spawned
    	local.result = registerev "kill" global/spawn_protect.scr::killed
        level.spawnprotectiontime = 35
        level.spawnprotectiontime = level.spawnprotectiontime * 2
    end
    
    spawned local.player:
    	wait .5
        local.player.spawn_orig = local.player.origin
    	//local.player nodamage
    	//local.player iprint ("protected: " + local.player.spawn_orig)
    	local.player light 0 1 0 40
        local.player.protected = 1
    
    	for(local.i = 0;local.i < level.spawnprotectiontime&&local.player.protected&&local.player.fireheld==0;local.i++)
        {
    	//local.player iprint ("You are: " + local.player.origin)
    	    if(vector_length(local.player.spawn_orig-local.player.origin) > 500)
            {
                //local.player.protected = 0
    			//local.player iprint "out of bounds"
    			//local.player lightOff
                //end
    			break
            }
            wait .1
    	}
        //local.player takedamage
    	//local.player iprint ("out of time: " + (vector_length(local.player.spawn_orig-local.player.origin)))
    	local.player lightOff
    	local.player.protected = 0
    end
    
    killed local.attacker local.player:
    	wait .1
     	local.player.died_orig = local.player.origin
    	local.player iprint ("Died: " + (vector_length(local.player.spawn_orig-local.player.died_orig))) // does not print
    	iprintln "Dead"	// prints
    
    	if((vector_length(local.player.spawn_orig-local.player.died_orig)) > 500) // Are you in your "protected zone"
    	{
            if(local.player.protected == 1) //Are you within the "protected" time limit
    		{
    			local.attacker hurt 100
    			local.attacker kill
    			iprintln "spawnkill"
    			end
    		}
        }
    end

  6. #16

    Default

    You dont have the Kill thread complete is like this:

    kill local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.player:

  7. #17
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,567

    Default

    Quote Originally Posted by [cB]SplatterGuts View Post
    Thanks, Ryback. I appreciate that. I was just using an old ass spawn protect script for the spawn protect parts. My goal was to get the killed section working nicely before tackling that. This makes things a lot easier. Thanks again.

    I made just a few adjustments to get it in working order. Turns out the vector_subtract wasn't needed in the code, just vector_length(vector1-vector2) (found from this thread - http://www.x-null.net/forums/showthr...-it-is-started)

    Had a hell of a time figuring that out :P

    I've added in the pieces that I want (lights on players being protected, disabling the script when firing a weapon, getting the script to take the actual player.origin of where you just spawned instead of referencing where you just died). The only issue now is the killed thread. It doesn't seem to be doing much of anything.... Any pointers there? Am I referencing the local.player.spawn_orig incorrectly between threads? I get the iprintln "dead", but not the local.player iprint "..." message, or any of the local.attacker stuff.

    whole scr
    main:  //by RyBack and the very cooperative doublekill
        if(level.spawnprotecton)
            end
        level.spawnprotecton = 1
    
        local.result = registerev "spawn" global/spawn_protect.scr::spawned
        local.result = registerev "kill" global/spawn_protect.scr::killed
        level.spawnprotectiontime = 35
        level.spawnprotectiontime = level.spawnprotectiontime * 2
    end
    
    spawned local.player:
        wait .5
        local.player.spawn_orig = local.player.origin
        //local.player nodamage
        //local.player iprint ("protected: " + local.player.spawn_orig)
        local.player light 0 1 0 40
        local.player.protected = 1
    
        for(local.i = 0;local.i < level.spawnprotectiontime&&local.player.protected&&local.player.fireheld==0;local.i++)
        {
        //local.player iprint ("You are: " + local.player.origin)
            if(vector_length(local.player.spawn_orig-local.player.origin) > 500)
            {
                //local.player.protected = 0
                //local.player iprint "out of bounds"
                //local.player lightOff
                //end
                break
            }
            wait .1
        }
        //local.player takedamage
        //local.player iprint ("out of time: " + (vector_length(local.player.spawn_orig-local.player.origin)))
        local.player lightOff
        local.player.protected = 0
    end
    
    killed local.attacker local.player:
        wait .1
         local.player.died_orig = local.player.origin
        local.player iprint ("Died: " + (vector_length(local.player.spawn_orig-local.player.died_orig))) // does not print
        iprintln "Dead"    // prints
    
        if((vector_length(local.player.spawn_orig-local.player.died_orig)) > 500) // Are you in your "protected zone"
        {
            if(local.player.protected == 1) //Are you within the "protected" time limit
            {
                local.attacker hurt 100
                local.attacker kill
                iprintln "spawnkill"
                end
            }
        }
    end
    Do as doublekill says and try to use iprintln instead of local.player iprint
    and turn developer to 1 and check your logs, will probably help.

  8. #18

    Default

    Quote Originally Posted by [cB]SplatterGuts View Post
    Thanks, Ryback. I appreciate that. I was just using an old ass spawn protect script for the spawn protect parts. My goal was to get the killed section working nicely before tackling that. This makes things a lot easier. Thanks again.

    I made just a few adjustments to get it in working order. Turns out the vector_subtract wasn't needed in the code, just vector_length(vector1-vector2) (found from this thread - http://www.x-null.net/forums/showthr...-it-is-started)

    Had a hell of a time figuring that out :P

    I've added in the pieces that I want (lights on players being protected, disabling the script when firing a weapon, getting the script to take the actual player.origin of where you just spawned instead of referencing where you just died). The only issue now is the killed thread. It doesn't seem to be doing much of anything.... Any pointers there? Am I referencing the local.player.spawn_orig incorrectly between threads? I get the iprintln "dead", but not the local.player iprint "..." message, or any of the local.attacker stuff.

    whole scr
    main:  //by RyBack and the very cooperative doublekill
        if(level.spawnprotecton)
            end
        level.spawnprotecton = 1
    
        local.result = registerev "spawn" global/spawn_protect.scr::spawned
    	local.result = registerev "kill" global/spawn_protect.scr::killed
        level.spawnprotectiontime = 35
        level.spawnprotectiontime = level.spawnprotectiontime * 2
    end
    
    spawned local.player:
    	wait .5
        local.player.spawn_orig = local.player.origin
    	//local.player nodamage
    	//local.player iprint ("protected: " + local.player.spawn_orig)
    	local.player light 0 1 0 40
        local.player.protected = 1
    
    	for(local.i = 0;local.i < level.spawnprotectiontime&&local.player.protected&&local.player.fireheld==0;local.i++)
        {
    	//local.player iprint ("You are: " + local.player.origin)
    	    if(vector_length(local.player.spawn_orig-local.player.origin) > 500)
            {
                //local.player.protected = 0
    			//local.player iprint "out of bounds"
    			//local.player lightOff
                //end
    			break
            }
            wait .1
    	}
        //local.player takedamage
    	//local.player iprint ("out of time: " + (vector_length(local.player.spawn_orig-local.player.origin)))
    	local.player lightOff
    	local.player.protected = 0
    end
    
    killed local.attacker local.player:
    	wait .1
     	local.player.died_orig = local.player.origin
    	local.player iprint ("Died: " + (vector_length(local.player.spawn_orig-local.player.died_orig))) // does not print
    	iprintln "Dead"	// prints
    
    	if((vector_length(local.player.spawn_orig-local.player.died_orig)) > 500) // Are you in your "protected zone"
    	{
            if(local.player.protected == 1) //Are you within the "protected" time limit
    		{
    			local.attacker hurt 100
    			local.attacker kill
    			iprintln "spawnkill"
    			end
    		}
        }
    end
    if((vector_length(local.player.spawn_orig-local.player.died_orig)) > 500)

    You are checking if the distance from the player's origin to the player's spawn point is greater than 500 units, is this what you want?

    This should work with the correct parameters for the killed thread :
    killed local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.player:
    	wait .1
     	local.player.died_orig = local.player.origin
    	local.dist = vector_length(local.player.spawn_orig-local.player.died_orig)
    	local.player iprint ("Died: " + local.dist)
    	iprintln "Dead"
    
    	if(local.dist < 500) // Are you in your "protected zone"
    	{
            if(local.player.protected == 1) //Are you within the "protected" time limit
    		{
    			local.attacker hurt 100
    			local.attacker kill
    			iprintln "spawnkill"
    			end
    		}
        }
    end

  9. #19
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,567

    Default

    true that ley0k, missed my eyes.
    splatter please write small replies. I can't read so much text

  10. #20

    Default

    Thanks guys. That did the trick. I really appreciate the help. The last bit of this is to respawn a full team if there are more than x spawn kills in a round.. I'm not finding much in the way of respawning on this forum. Any ideas?
    Here's the full code even though it hurts ryback's eyes ;P

    // spawn protection, huge thanks to x-null:
    // ryback
    // doublekill
    // ley0k
    
    main:
        if(level.spawnprotecton)
            end
        level.spawnprotecton = 1
    
        local.result = registerev "spawn" global/spawn_protect.scr::spawned
    	local.result = registerev "kill" global/spawn_protect.scr::killed
        level.spawnprotectiontime = 350
        level.spawnprotectiontime = level.spawnprotectiontime * 2
    
    	level.axisslaughter = 0
    	level.alliedslaughter = 0
    	level.slaughterhouse = 2
    
    	thread reboot_check
    
    end
    
    spawned local.player:
    	wait .5
        local.player.spawn_orig = local.player.origin
    	local.player light 0 1 0 40
        local.player.protected = 1
    
    	for(local.i = 0;local.i < level.spawnprotectiontime&&local.player.protected&&local.player.fireheld==0;local.i++)
        {
    	    if(vector_length(local.player.spawn_orig-local.player.origin) > 500)
            {
    			local.player lightOff
    			local.player.protected = 0
    			end
            }
            wait .1
    	}
    	local.player lightOff
    	local.player.protected = 0
    end
    
    killed local.attacker local.damage local.inflictor local.position local.direction local.normal local.knockback local.damageflags local.meansofdeath local.location local.player:
    	wait .1
     	local.player.died_orig = local.player.origin
    	local.zone = vector_length(local.player.spawn_orig-local.player.died_orig)
    	local.player lightOff
    
    	if(local.zone < 500)
    	{
            if(local.player.protected == 1)
    		{
    			if(local.player.dmteam == allies)
    			{
    				level.alliedslaughter++
    				iprintln level.alliedslaughter
    				iprintln ("Allied Slaughter: " + level.alliedslaughter + ". " + ((level.slaughterhouse)-(level.alliedslaughter)) + " more spawn kills until Allied Reboot.")
    			}
    			if(local.player.dmteam == axis)
    			{
    				level.axisslaughter++
    				iprintln level.axisslaughter
    				iprintln ("Axis Slaughter: " + level.axisslaughter + ". " + ((level.slaughterhouse)-(level.axisslaughter)) + " more spawn kills until Axis Reboot.")
    			}
    			local.attacker hurt 20
    			local.attacker addkills -1
    			local.attacker stufftext "say I am a spawn killer!"
    			end
    		}
        }
    end
    
    reboot_check:
    while(1)
    {
    if(level.alliedslaughter >= level.slaughterhouse)
    {
    	wait .25
    	//stuffsrv !allies ftmelt // this is how i melt a whole team in rcon, stuffsrv didn't work though
    	//thread global/libmef/ft.scr::melt_player local.player.dmteam	// my rcon command uses "thread global/...melt_player self" so I thought maybe local.player.dmteam would be useful? it didn't work.
    	//thread global/libmef/ft.scr::reboot_allies // added a thread inside the ft.scr that uses the melt_player local.player thread, but it's team specific.. Didn't work
    	level.alliedslaughter = 0
    	stuffsrv "say Allies have been thawed!"
    }
    if(level.axisslaughter >= level.slaughterhouse)
    {
    	wait .25
    	//stuffsrv !allies ftmelt
    	//thread global/libmef/ft.scr::reboot_axis
    	level.axisslaughter = 0
    	stuffsrv "say Axis have been thawed!"
    }
    wait 1
    }
    waitframe
    end


    The piece I really need help with though is here, under the reboot_check:

    if(level.alliedslaughter >= level.slaughterhouse)
    {
    	wait .25
    	//stuffsrv !allies ftmelt // this is how i melt a whole team in rcon, stuffsrv didn't work though
    	//thread global/libmef/ft.scr::melt_player local.player.dmteam	// my rcon command uses "thread global/...melt_player self" so I thought maybe local.player.dmteam would be useful? it didn't work.
    	//thread global/libmef/ft.scr::reboot_allies // added a thread inside the ft.scr that uses the melt_player local.player thread, but it's team specific.. Didn't work
    	level.alliedslaughter = 0
    	stuffsrv "say Allies have been thawed!"
    }

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •